package cn.edu.sjtu.se.peakfactory.dao.bean;

import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import cn.edu.sjtu.se.lchang.socialnetwork.dao.bean.Location;

@Entity
@Table(name = "PEAK_FACTORY_COUPON_TABLE")
public class Coupon {
	private Long id;
	private String name;
	private String detail;
	private Date startTime;
	private Date dueTime;
	private List<Location> locations;
	private List<Formula> formulas;

	private Integer count;
	private Integer used;

	private Integer status;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@Column(name = "COUPON_NAME")
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "COUPON_DETAIL")
	public String getDetail() {
		return detail;
	}

	public void setDetail(String detail) {
		this.detail = detail;
	}

	@Column(name = "START_TIME")
	public Date getStartTime() {
		return startTime;
	}

	public void setStartTime(Date startTime) {
		this.startTime = startTime;
	}

	@Column(name = "DUE_TIME")
	public Date getDueTime() {
		return dueTime;
	}

	public void setDueTime(Date dueTime) {
		this.dueTime = dueTime;
	}
	
	@ManyToMany
	@JoinTable(name = "PEAK_FACTORY_COUPON_LOCATION_TABLE", joinColumns = @JoinColumn(name = "COUPON_ID"), inverseJoinColumns = @JoinColumn(name = "LOCATION_ID"))
	public List<Location> getLocations() {
		return locations;
	}

	public void setLocations(List<Location> locations) {
		this.locations = locations;
	}

	@ManyToMany
	@JoinTable(name = "PEAK_FACTORY_COUPON_LOCATION_TABLE", joinColumns = @JoinColumn(name = "COUPON_ID"), inverseJoinColumns = @JoinColumn(name = "FORMULA_ID"))
	public List<Formula> getFormulas() {
		return formulas;
	}

	public void setFormulas(List<Formula> formulas) {
		this.formulas = formulas;
	}

	@Column(name = "COUPON_COUNT")
	public Integer getCount() {
		return count;
	}

	public void setCount(Integer count) {
		this.count = count;
	}

	@Column(name = "COUPON_USED")
	public Integer getUsed() {
		return used;
	}

	public void setUsed(Integer used) {
		this.used = used;
	}

	@Column(name = "COUPON_STATUS")
	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

}
